﻿@using System.Reflection;
@using YUCodeGen.Utils;
@model PropertyInfo
    <div class="form-group row">
        <label for="@Model.Name" class="col-sm-3 col-form-label">@Model.Name:</label>
        <div class="col-sm-9">
@if (PageUtil.IsMultipleText(Model))
{
                <textarea formControlName="@Model.Name" @Html.Raw(PageUtil.GetRequired(Model)) @Html.Raw(PageUtil.GetMaxlength(Model)) id="@Model.Name"></textarea>
}
else
{
                <input type="@(PageUtil.GetInputType(Model))" formControlName="@Model.Name" @Html.Raw(PageUtil.GetRequired(Model)) @Html.Raw(PageUtil.GetMaxlength(Model)) @Html.Raw(PageUtil.GetRegularExp(Model)) id="@Model.Name" />
}
            <div *ngIf="@(Model.Name).invalid && (@(Model.Name).dirty || @(Model.Name).touched)" class="alert alert-danger">
@if (!String.IsNullOrEmpty(PageUtil.GetRequired(Model)))
{
                    <div *ngIf="@(Model.Name).errors.required">@(Model.Name) is required.</div>
}
@if (!String.IsNullOrEmpty(PageUtil.GetMinLengthValue(Model)))
{
                    <div *ngIf="@(Model.Name).errors.minlength">@(Model.Name) must be at least @PageUtil.GetMinLengthValue(Model) characters long.</div>
}
@if (PageUtil.IsEmail(Model))
{
                    <div *ngIf="@(Model.Name).errors.email">@(Model.Name) must be a email address.</div>
}
@if (PageUtil.HasForbiddenName(Model))
{
                    <div *ngIf="@(Model.Name).errors.forbiddenName">@(Model.Name) cannot be this value.</div>
}
@if (PageUtil.HasRegularExp(Model))
{
                    <div *ngIf="@(Model.Name).errors.requiredPattern">@(Model.Name) must follow this pattern:{{@(Model.Name).errors.requiredPattern.value}}</div>
}
            </div>
        </div>
    </div>
